
CVscript;

%{
k = @(x,x2) kernel_intersection(x, x2);
[results.intersect, info, yhat] = kernel_liblinear(Xtrain, Ytrain, XminiTest, zeros(size(XminiTest,1),1), k);

p = exp(info.vals);
p = bsxfun(@times, p, 1./sum(p,2));

p2 = info.vals;
p2 = bsxfun(@minus, p2, min(p2,[],2));
p2 = bsxfun(@rdivide, p2, sum(p2,2));

ratings = [1 2 4 5];
% Calculated Expected Value
YhatE = sum(bsxfun(@times, p2, ratings),2);

% Calc RMSE
n = numel (YminiTest);
rmseMini = sqrt (sum ((YminiTest - YhatE) .^ 2) / n);

% Calc RMSE
n = numel (YminiTest);
rmseMini2 = sqrt (sum ((YminiTest - yhat) .^ 2) / n);
%}

